package edu.wpi.first.wpilibj.templates.commands;

/**
 * This class encapsulates the methods and variables needed for the drive station
 * operator to drive the robot with the joystick
 * @author anne
 */
public class DriveWithJoystick extends CommandBase {
    
    public DriveWithJoystick() {
        /**
         * requires() is used to declare subsystem dependencies
         * Since this command will need to control the chassis subsystem,
         * we need to mark this to insure that if the scheduler schedules
         * multiple commands to control the drive train at the same time,
         * any conflicts are handled in an orderly and predictable manner.
         */
        requires(chassis); // reserve chassis subsystem
    }

    /**
     * This method is called just before this Command runs the first time
     * so that variables can be initialized.  The reason "first time" is used
     * in this comment is that the command will be programmed to run once. 
     * However, the command may have its "execute" method called more than 
     * once by the scheduler until the command is completed (ie. in this case
     * the time out number of seconds have passed). 
     */
    protected void initialize() {
    }

    /**
     * This method is called repeatedly when this Command is scheduled to run
     */
    protected void execute() {
        /**
         * Invoke drive train (chassis) subsystem's method to drive the 
         * robot with the joystick. The driver station operator interface
         * is invoked to get the current joystick object in use.
         */
        chassis.driveWithJoystick(oi.getDriveJoystick());
    }

    /**
     * This method is called by the scheduler to see if the command has completed.
     * Since we are intending this command to "execute forever" as a default 
     * command until it is interrupted by another command, this routine is set
     * to always return false.  Therefore, the scheduler will continue calling 
     * this command's execute()method until the command is interrupted.
     */
    protected boolean isFinished() {
        return false; // We never finished
    }

    /**
     * Called once after isFinished returns true
     */
    protected void end() {
    }

    /**
     * This routine is called when another command which requires the chassis
     * subsystem is scheduled to run.
     */
    protected void interrupted() {
    }
}
